package com.lxp.controller;

import com.lxp.service.OssService;
import com.lxp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/eduOss")
public class OssController {
    @Autowired
    private OssService ossService; //注入服务类

    @PostMapping("/uploadAvatar")
    public R uploadAvatar(MultipartFile file){//获取上传到的文件

        //获取上传到Oss的url并返回
        String url=ossService.uploadAvatar(file);
        return R.ok().data("url",url);
    }
}
